<!-- group_option.html -->
{% init error = None %}
{% init is_iframe = False %}
{% init file = Storage(id = 0, parent_id=0, priority = 0) %}

{% if file != None and _has_login %}
    <div class="dropdown">
      <span class="dropdown-btn link btn">更多▾</span>
      <div class="dropdown-content">
        <a class="dropdown-option" href="/note/stick?id={{file.id}}">
            置顶
            {% if file.priority == 1 %}<i class="fa fa-check"></i>{% end %}
        </a>

        <a class="dropdown-option" href="/note/reset?id={{file.id}}">
            普通
            {% if file.priority == 0 %}<i class="fa fa-check"></i>{% end %}
        </a>

        <a class="dropdown-option link" href="/note/archive?id={{file.id}}">
            归档
            {% if file.priority == -1 %}
                <i class="fa fa-check"></i>
            {% end %}
        </a>
        
        {% if str(file.id) != "0" %}
            <a class="dropdown-option" href="javascript:renameNote('{{file.id}}', '{{file.name}}')">重命名</a>
        {% end %}

        <a class="dropdown-option" href="/note/management?parent_id={{file.id}}">批量操作</a>
        <!--
        <a class="dropdown-option" href="/note/view?id={{file.id}}&orderby=mtime_desc&page={{!page}}">按时间倒序</a>
        <a class="dropdown-option" href="/note/view?id={{file.id}}&orderby=name&page={{!page}}">按名称顺序</a>
        <a class="dropdown-option" href="/note/view?id={{file.id}}&orderby=name_desc&page={{!page}}">按名称倒序</a>
        -->

        {% if file.size == 0 %}
            <a class="dropdown-option-red" href="javascript:remove('{{file.id}}', '{{file.name}}')">删除</a>
        {% end %}
      </div>
    </div>
{% end %}

{% if error != "" and error != None%}
    <div class="col-md-12 error">
        {{error}}
    </div>
{% end %}

{% include note/script/rename_script.html %}

<script type="text/javascript">
function remove(id, name, parentId) {
    var confirmed = confirm("确定删除'" + name + "'?");
    if (confirmed) {
        $.post("/note/remove", {id:id}, function (resp) {
            var code = resp.code;
            if (code != "success") {
                alert(resp.message);
            } else {
                if (parentId) {
                    window.location.href = "/note/view?id="+parentId;
                } else {
                    window.location.href = "/";
                }
            }
        })
    }
}
</script>